﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_QuenMk1 : System.Web.UI.UserControl
{
    private UsersBLL usersBLL;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.usersBLL = new UsersBLL();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string username = this.txtUsername.Text;
        string email = this.txtEmail.Text;

        Users user = this.usersBLL.GetIUsers.GetUserByUsername(username);


        if (user.Email.Equals(email))
        {
            string body = "Mật khẩu của tài khoản " + username + " là:  " + user.Password;
            
            bool result = MailHandle.SendEmail(user.Email, "Lấy lại mật khẩu", body);

            if (result)
                Response.Redirect("Login.aspx");
            else
                Response.Redirect("Fail.aspx");
            
        }
    }
}